package cn.yunhe.interceptor;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import java.util.Calendar;
import java.util.Map;

public class TimeInterceptor extends AbstractInterceptor {
    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        Calendar ca=Calendar.getInstance();
        int time=ca.get(Calendar.HOUR_OF_DAY);
        if (time>8&&time<20){
            ActionContext cxt=invocation.getInvocationContext();
            Map request= (Map) cxt.get("request");
            request.put("msg","<h1>系统维护中请稍后再进行登录~</h1>");
            return "error";
        }else
        return invocation.invoke();
    }
}
